<?php

namespace app\admin\controller\sms;
use app\admin\model\sms\SmsserviceModel;
use app\common\annotation\NodeAnnotation;


use app\common\controller\Admin;
use app\common\traits\ControllerCurd;

/**
 * Class Administrator
 * @package app\admin\controller
 * @NodeAnnotation(
 *     title="短信服务",
 *     parent="default",
 *     is_menu=1,
 *     is_view=0,
 *     auth=1,
 *     icon="/material/sms.png"
 * )
 */
class Smsservice extends Admin
{
    use ControllerCurd;

    public $model;

    public function initialize()
    {
        parent::initialize();
        $this->model = new SmsserviceModel();
    }

    /**
     * @NodeAnnotation(
     *     title="平台列表",
     *     parent="admin/sms.smsservice",
     *     is_menu=1,
     *     is_view=1,
     *     auth=1,
     *     MenuRoot="admin/sms.smsservice"
     * )
     */
    public function index()
    {
        $keywords = $this->request->param("keywords");

        $where  = [];

        if($keywords) array_push($where,["name","eq",$keywords]);


//       echo system("php /www/wwwroot/lve123.com/tp5admin/public/swoole/task.php",$descriptorspec);

        $data = $this->model->selectPageDatas(1,20,$where);

        return view('',[
            "dataList" => $data,
            "search"   => [
                "keywords" => $keywords,
            ]
        ]);
    }


    /**
     * @NodeAnnotation(
     *     title="创建短信服务",
     *     parent="admin/sms.smsservice",
     *     is_menu=0,
     *     is_view=1,
     *     auth=1,
     *     MenuRoot="admin/sms.smsservice"
     * )
     */
    public function addsms()
    {
        $this->add(url('admin/sms.smsservice/index'));
        return view();
    }

    /**
     * @NodeAnnotation(
     *     title="编辑短信服务",
     *     parent="admin/sms.smsservice",
     *     is_menu=0,
     *     is_view=1,
     *     auth=1,
     *     MenuRoot="admin/sms.smsservice"
     * )
     */
    public function editsms()
    {
        $id = $this->request->param("id",0,'intval');
        $data = $this->model->where('id',$id)->find();
        $this->edit(url('admin/sms.smsservice/index'));
        return view('',[
            'data' => $data
        ]);
    }

    /**
     * @NodeAnnotation(
     *     title="删除短信服务",
     *     parent="admin/sms.smsservice",
     *     is_menu=0,
     *     is_view=1,
     *     auth=1,
     *     MenuRoot="admin/sms.smsservice"
     * )
     */
    public function delsms()
    {
        $this->del(url('admin/sms.smsservice/index'));
    }
}